package com.jy.adscm.spss.service.impl;

        import com.alibaba.fastjson.JSONArray;
        import com.alibaba.fastjson.JSONObject;
        import com.baomidou.mybatisplus.service.impl.ServiceImpl;
        import com.jy.adscm.spss.bean.*;
        import com.jy.adscm.spss.mapper.mysql.Base_commodityinfoMapper;
        import com.jy.adscm.spss.mapper.mysql.Base_incomeexpenditureMapper;
        import com.jy.adscm.spss.service.Base_commodityinfoService;
        import com.jy.adscm.spss.utils.DateUtils;
        import com.jy.adscm.utils.AdscmBaseUtils;
        import org.apache.ibatis.annotations.Param;
        import org.springframework.beans.factory.annotation.Autowired;
        import org.springframework.stereotype.Service;

        import java.math.BigDecimal;
        import java.text.ParseException;
        import java.text.SimpleDateFormat;
        import java.util.*;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author yyy
 * @since 2018-11-08
 */
@Service
public class Base_commodityinfoServiceImpl extends ServiceImpl<Base_commodityinfoMapper, Base_commodityinfo> implements Base_commodityinfoService {

    @Autowired
    Base_commodityinfoMapper base_commodityinfoMapper;
    @Autowired
    Base_incomeexpenditureMapper baseIncomeexpenditureMapper;


    SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd");

    /**
     *获取销售采购两年内所有周
     * @return
     */
    private static List<Base_commodityinfo> getTwoYearWeek(){
        SimpleDateFormat sd=new SimpleDateFormat("yyyy"  );
        List<Base_commodityinfo> list=new ArrayList<Base_commodityinfo>();
        String thisYear = sd.format(new Date());
        for (int j=2018;j<=Integer.valueOf(thisYear)+1;j++){
            int x=30;
            if (j==2018){
                for(int i =x; i<=52;i++){
                    Base_commodityinfo base=new Base_commodityinfo();
                    if (i<10){
                        base.setWhereWeek(j+":0"+i);
                        base.setSJWHEREWEEK(j+":0"+i);
                    }else {
                        base.setWhereWeek(j+":"+i);
                        base.setSJWHEREWEEK(j+":"+i);

                    }
                    list.add(base);
                }
            }else {
                for(int i =1; i<=52;i++){
                    Base_commodityinfo base=new Base_commodityinfo();
                    if (i<10){
                        base.setWhereWeek(j+":0"+i);
                        base.setSJWHEREWEEK(j+":0"+i);
                    }else {
                        base.setWhereWeek(j+":"+i);
                        base.setSJWHEREWEEK(j+":"+i);

                    }
                    list.add(base);
                }
            }

        }
        return list;
    }

    @Override
    public Map<String,Object> loadPlanTotal(String rwlx) throws Exception{
//        updateWeek();
        Map<String,Object> map =new HashMap<>();

        map.put("SaleResult", LoadTotal(rwlx));

        return map;
    }

    /**
     * 加载销售采购总额
     * @param rwlx
     * @return
     */
    private  List<Base_commodityinfo> LoadTotal (String rwlx){
        List<Base_commodityinfo> planTotal = base_commodityinfoMapper.getPlanTotal(rwlx);
        List<Base_commodityinfo> practicalTotal = base_commodityinfoMapper.getPracticalTotal(rwlx);
        List<Base_commodityinfo> twoYearWeek = getTwoYearWeek();

        for (Base_commodityinfo twoYear : twoYearWeek) {
            for (Base_commodityinfo practical : practicalTotal) {
                if (twoYear.getSJWHEREWEEK().equals(practical.getSJWHEREWEEK())){
                    twoYear.setSjtotal(practical.getSPSJZJ());
                }
            }
            for (Base_commodityinfo plan : planTotal) {

                if(twoYear.getWhereWeek().equals(plan.getWhereWeek())){
                    twoYear.setTotal(plan.getSPJHZJ());
                }
            }
        }

        return twoYearWeek;
    }
    /**
     * 修改采购销售周
     * @throws ParseException
     */
    public    void    updateWeek() throws ParseException {

        List<Base_commodityinfo> week = base_commodityinfoMapper.getWeek() ;
        for (Base_commodityinfo base : week) {
            if (base.getSPJHSFSJ()!=null){
                base_commodityinfoMapper.updatePlanWeek(DateUtils.getWeek(base.getSPJHSFSJ()),base.getSPID());
            }
            if (base.getSFKRQ()!=null){
                base_commodityinfoMapper.updatePracticalWeek(DateUtils.getWeek(sdf.parse(base.getSFKRQ())),base.getSPID());
            }

        }
    }

    /**
     * 计算结余
     * @return
     */
    public List<Base_Result> queryPlanTotal(){
        List<Base_commodityinfo> twoYearWeek = getTwoYearWeek();
        List<Base_incomeexpenditure> planTotal = baseIncomeexpenditureMapper.getPlanTotal("1");//获取收入总额
        List<Base_incomeexpenditure> planTotal2 = baseIncomeexpenditureMapper.getPlanTotal("2");//获取支出总额
        List<Base_Result> list =new ArrayList<>();
        List<Base_commodityinfo> planTotal1 = base_commodityinfoMapper.getPlanTotal("2");//获取销售总额
        List<Base_commodityinfo> planTotal3 = base_commodityinfoMapper.getPlanTotal("1");//获取采购总额
        List<Base_incomeexpenditure> practicalTotal = baseIncomeexpenditureMapper.getPracticalTotal("1");//获取实际收入总额

        List<Base_incomeexpenditure> practicalTotal1 = baseIncomeexpenditureMapper.getPracticalTotal("2");//获取实际支出总额

        List<Base_commodityinfo> practicalTotal2 = base_commodityinfoMapper.getPracticalTotal("2");//获取实际销售总额


        List<Base_commodityinfo> practicalTotal3 = base_commodityinfoMapper.getPracticalTotal("1");//获取实际采购总额


        double tmp=0;
        double tmp1=0;
        double tmp3=0;
        double tmp4=0;
        double next=0;
        double next1=0;
        double sr=0;
        double sr1=0;

        for (int i=0;i<twoYearWeek.size();i++) {
            Base_Result result=new Base_Result();

            for (Base_incomeexpenditure sz : planTotal) {

                if (AdscmBaseUtils.getInstance().isNotEmpty(sz.getWhereWeek(),null)){
                    if (twoYearWeek.get(i).getWhereWeek().equals(sz.getWhereWeek())){
                        tmp=Double.valueOf(sz.getJHJE());
                    }
                }

            }

            for (Base_commodityinfo cgxs : planTotal1) {
                if (twoYearWeek.get(i).getWhereWeek().equals(cgxs.getWhereWeek())){
                    tmp+=cgxs.getSPJHZJ();
                }
            }

            for (Base_incomeexpenditure sz : planTotal2) {
                if (twoYearWeek.get(i).getWhereWeek().equals(sz.getWhereWeek())){
                    if (AdscmBaseUtils.getInstance().isNotEmpty(sz.getJHJE(),null)){
                        tmp1=Double.valueOf(sz.getJHJE());
                    }

                }
            }

            for (Base_commodityinfo cgxs : planTotal3) {
                if (twoYearWeek.get(i).getWhereWeek().equals(cgxs.getWhereWeek())){
                    tmp1+=cgxs.getSPJHZJ();
                }
            }

            for (Base_incomeexpenditure sjsz : practicalTotal) {
                if (twoYearWeek.get(i).getWhereWeek().equals(sjsz.getSJWHEREWEEK())){
                    tmp3=Double.valueOf(sjsz.getSJJE());
                }
            }

            for (Base_commodityinfo sjxs : practicalTotal2) {
                if (twoYearWeek.get(i).getWhereWeek().equals(sjxs.getSJWHEREWEEK())){
                    tmp3+=sjxs.getSPSJZJ();
                }
            }

            for (Base_incomeexpenditure sjsz : practicalTotal1) {
                if (twoYearWeek.get(i).getWhereWeek().equals(sjsz.getSJWHEREWEEK())){
                    tmp4=Double.valueOf(sjsz.getSJJE());
                }
            }

            for (Base_commodityinfo sjcg : practicalTotal3) {
                if (twoYearWeek.get(i).getWhereWeek().equals(sjcg.getSJWHEREWEEK())){
                    tmp4+=sjcg.getSPSJZJ();
                }
            }


            if (i==0) {
                next=tmp-tmp1;
                next1=tmp3-tmp4;
            }else {
                sr=next+tmp;
                next=sr-tmp1;
                sr1=next1+tmp3;
                next1=sr1-tmp4;
            }

            BigDecimal bd = new BigDecimal(next);
            result.setJhjy(Double.valueOf(bd.toPlainString()));
            result.setSjjy(next1);
            result.setWhereWeek(twoYearWeek.get(i).getWhereWeek());
            int year=Integer.valueOf(twoYearWeek.get(i).getWhereWeek().toString().substring(0,4));
            int week=Integer.valueOf(twoYearWeek.get(i).getWhereWeek().toString().substring(5,7));
            result.setWeekDate(DateUtils.getWeekDays(year,week));
            list.add(result);
            tmp=0;
            tmp1=0;
            tmp3=0;
            tmp4=0;
        }

        return list;

    }

    @Override
    public Map<String, Object> getByDetailed(String whereWeek, String rwlx) {
        Map<String, Object> map=new HashMap<String, Object>();
        if ("1".equals(rwlx)||"2".equals(rwlx)) {
            List<SalePurchase> byDetailed = base_commodityinfoMapper.getByDetailed(whereWeek,rwlx);
            SimpleDateFormat sd=new SimpleDateFormat("yyyy-MM-dd");
            int time=0;
            for (SalePurchase salePurchase : byDetailed) {
                if (salePurchase.getPlanarrivedtime()!=null&&salePurchase.getSpjhsfsj()!=null) {
                    try {
                        long a=salePurchase.getSpjhsfsj().getTime()-sd.parse(salePurchase.getPlanarrivedtime()).getTime();
                        time=(int) (a/1000/60/60/24);
                        salePurchase.setDays(time);
                    } catch (ParseException e) {
                        e.printStackTrace();
                    }
                }
            }

            map.put("jh", byDetailed);
        }
        if ("3".equals(rwlx)) {
            map.put("sj", base_commodityinfoMapper.getBySaleDetailed(whereWeek, "1"));
        }
        if ("4".equals(rwlx)) {
            List<SalePurchase> byDetailed = base_commodityinfoMapper.getBySaleDetailed(whereWeek, "2");
            SimpleDateFormat sd=new SimpleDateFormat("yyyy-MM-dd");
            int time=0;
            for (SalePurchase salePurchase : byDetailed) {
                if (salePurchase.getSFKRQ()!=null&&salePurchase.getSFHRQ()!=null) {
                    try {
                        long a=sd.parse(salePurchase.getSFKRQ()).getTime()-sd.parse(salePurchase.getSFHRQ()).getTime();
                        time=(int) (a/1000/60/60/24);
                        salePurchase.setDays(time);
                    } catch (ParseException e) {

                        e.printStackTrace();
                    }
                }
            }
            map.put("sj",byDetailed );

        }

        return map;
    }

    @Override
    public Map<String, Map<String, Object>> getStackingChart(String rwlx) {
        List<String> onlyWeek = DateUtils.getTwoYearWeek();
        List<SalePurchase> stackingChart = base_commodityinfoMapper.getStackingChart(rwlx);
        List<String> customer = base_commodityinfoMapper.getCustomer(rwlx);
        Map<String, Object> tMap=null;
        Map<String,Map<String, Object> > map=new LinkedHashMap<String, Map<String,Object>>();

        for (String only : onlyWeek) {
            tMap=new HashMap<String, Object>();
            for (String string : customer) {
                List<SalePurchase> list=new ArrayList<SalePurchase>();
                for (SalePurchase salePurchase : stackingChart) {
                    if (only.equals(salePurchase.getWhereWeek())&&string.equals(salePurchase.getName())) {
                        list.add(salePurchase);

                        tMap.put(string,list);
                    }

                }

            }
            for (String str : customer) {
                if (tMap.get(str)==null) {
                    tMap.put(str,null);
                }
            }
            String time=DateUtils.getWeekDays(Integer.valueOf(only.substring(0,4)),Integer.valueOf(only.substring(5)));
            map.put(only+time,tMap);
        }
        return map;
    }

    @Override
    public Map<String, Object> getSZDtail() throws Exception {
        Map<String, Object> map=new HashMap<String, Object>();
        SimpleDateFormat sd=new SimpleDateFormat("yyyy-MM");
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
        List<SalePurchase> allCGDetail = base_commodityinfoMapper.getAllCGDetail("1");
        double cgTotal=0;
        double xsTotal=0;
        double srTotal=0;
        double zcTotal=0;
        int times=0;
        for (SalePurchase salePurchase : allCGDetail) {
            cgTotal+=salePurchase.getSpjhzj();
            if (salePurchase.getSpjhsfsj()!=null&&salePurchase.getPlanarrivedtime()!=null) {
                long a=salePurchase.getSpjhsfsj().getTime()-sdf.parse(salePurchase.getPlanarrivedtime()).getTime();
                times=(int) (a/1000/60/60/24);
                salePurchase.setDays(times);

            }
        }
        map.put("CGAllResult", allCGDetail);
        map.put("CGTotal", cgTotal);
        List<SalePurchase> allCGDetail1 = base_commodityinfoMapper.getAllCGDetail("2");
        times=0;
        for (SalePurchase salePurchase : allCGDetail1) {

            if (salePurchase.getSpjhsfsj()!=null&&salePurchase.getPlanarrivedtime()!=null) {
                long a=salePurchase.getSpjhsfsj().getTime()-sdf.parse(salePurchase.getPlanarrivedtime()).getTime();
                times=(int) (a/1000/60/60/24);
                salePurchase.setDays(times);

            }
            xsTotal+=salePurchase.getSpjhzj();
        }
        map.put("XSTotal", xsTotal);
        map.put("XSAllResult", allCGDetail1);
        List<SZResult> allSRDetail = base_commodityinfoMapper.getAllSRDetail("2");
        for (SZResult szResult : allSRDetail) {
            if (AdscmBaseUtils.getInstance().isNotEmpty(szResult.getJHJE(),null)){
                zcTotal+=szResult.getJHJE();
            }

        }
        map.put("ZCAllResult", allSRDetail);
        map.put("ZCTotal", zcTotal);

        List<SZResult> allSRDetail1 = base_commodityinfoMapper.getAllSRDetail("1");
        for (SZResult szResult : allSRDetail1) {

            srTotal+=szResult.getJHJE();
        }
        map.put("SRAllResult", allSRDetail1);
        map.put("SRTotal", srTotal);



        String startTime= sd.format(new Date())+"-01";
        String year=startTime.substring(0,4);
        String month=startTime.substring(5,7);
        String endTime = DateUtils.getLastDayOfMonth1(Integer.valueOf(year),Integer.valueOf(month));

        double CGmonthTotal=0;
        double XSmonthTotal=0;
        double ZCmonthTotal=0;
        double SRmonthTotal=0;
        double XSActualTotal=0;
        double CGActualTotal=0;
        double CGTotal=0;
        double XSTotal=0;
        double ZCTotal=0;
        double SRTotal=0;

        for (int i = 0; i <12; i++) {
            List<SalePurchase> mouthCGDetail = base_commodityinfoMapper.getMouthCGDetail(DateUtils.getThatDate(startTime, i,2), DateUtils.getThatDate(endTime, i,2));
            for (SalePurchase salePurchase : mouthCGDetail) {
                if (salePurchase.getSpjhzj()!=null) {
                    CGmonthTotal+=salePurchase.getSpjhzj();
                }
                if (salePurchase.getSpsjzj()!=null) {
                    CGActualTotal+=salePurchase.getSpsjzj();
                }
            }

            map.put("CGMonth"+i,mouthCGDetail);
            map.put("CGMonthTotal"+i, CGmonthTotal);
            map.put("CGActualTotal"+i, CGActualTotal);
            CGmonthTotal=0;
            int time=0;
            List<SalePurchase> mouthXSDetail = base_commodityinfoMapper.getMouthXSDetail(DateUtils.getThatDate(startTime, i,2), DateUtils.getThatDate(endTime, i,2));
            for (SalePurchase salePurchase : mouthXSDetail) {
                if (salePurchase.getSpjhzj()!=null) {
                    XSmonthTotal+=salePurchase.getSpjhzj();
                }
                if (salePurchase.getSpsjzj()!=null) {
                    XSActualTotal+=salePurchase.getSpsjzj();
                }


                if (salePurchase.getSpjhsfsj()!=null&&salePurchase.getPlanarrivedtime()!=null) {
                    long a=salePurchase.getSpjhsfsj().getTime()-sdf.parse(salePurchase.getPlanarrivedtime()).getTime();
                    time=(int) (a/1000/60/60/24);
                    salePurchase.setDays(time);

                }


            }
            map.put("XSMonth"+i, mouthXSDetail);
            map.put("XSMonthTotal"+i, XSmonthTotal);
            map.put("XSActualTotal"+i, XSActualTotal);
            XSmonthTotal=0;
            XSActualTotal=0;
            List<SZResult> mouthZCDetail = base_commodityinfoMapper.getMouthZCDetail(DateUtils.getThatDate(startTime, i,2), DateUtils.getThatDate(endTime, i,2));
            for (SZResult szResult : mouthZCDetail) {
                if (szResult.getJHJE()!=null) {
                    ZCmonthTotal+=szResult.getJHJE();
                }

            }
				/*SZResult sz=new SZResult();
				sz.setTotal(String.valueOf(ZCmonthTotal));
				mouthZCDetail.add(sz);*/
            map.put("ZCMonth"+i, mouthZCDetail);
            map.put("ZCMonthTotal"+i, ZCmonthTotal);
            ZCmonthTotal=0;
            List<SZResult> mouthSRDetail = base_commodityinfoMapper.getMouthSRDetail(DateUtils.getThatDate(startTime, i,2), DateUtils.getThatDate(endTime, i,2));

            for (SZResult szResult : mouthSRDetail) {
                if (szResult.getJHJE()!=null) {
                    SRmonthTotal+=szResult.getJHJE();
                }

            }
				/*SZResult szr=new SZResult();
				szr.setTotal(String.valueOf(SRmonthTotal));
				mouthSRDetail.add(szr);*/
            map.put("SRMonth"+i, mouthSRDetail);
            map.put("SRMonthTotal"+i, SRmonthTotal);
            SRmonthTotal=0;
        }
        List<SalePurchase> YearCGDetail = base_commodityinfoMapper.getMouthCGDetail(DateUtils.getThatDate(startTime,0,1), DateUtils.getThatDate(endTime, 1,1));
        for (SalePurchase salePurchase : YearCGDetail) {
            CGTotal+=salePurchase.getSpjhzj();
        }
        List<SalePurchase> YearXSDetail = base_commodityinfoMapper.getMouthXSDetail(DateUtils.getThatDate(startTime,0,1), DateUtils.getThatDate(endTime, 1,1));
        int time=0;
        for (SalePurchase salePurchase : YearXSDetail) {
            XSTotal+=salePurchase.getSpjhzj();
            if (salePurchase.getSpjhsfsj()!=null&&salePurchase.getPlanarrivedtime()!=null) {
                long a=salePurchase.getSpjhsfsj().getTime()-sdf.parse(salePurchase.getPlanarrivedtime()).getTime();
                time=(int) (a/1000/60/60/24);
                salePurchase.setDays(time);

            }

        }
        List<SZResult> YearZCDetail = base_commodityinfoMapper.getMouthZCDetail(DateUtils.getThatDate(startTime,0,1), DateUtils.getThatDate(endTime, 1,1));
        for (SZResult szResult : YearZCDetail) {
            ZCTotal+=szResult.getJHJE();
        }
        List<SZResult> YearSRDetail = base_commodityinfoMapper.getMouthSRDetail(DateUtils.getThatDate(startTime,0,1), DateUtils.getThatDate(endTime, 1,1));
        for (SZResult szResult : YearSRDetail) {
            SRTotal+=szResult.getJHJE();
        }
        map.put("CGYear", YearCGDetail);
        map.put("CGYearTotal", CGTotal);
        map.put("XSYear", YearXSDetail);
        map.put("XSYearTotal", XSTotal);
        map.put("ZCYear", YearZCDetail);
        map.put("ZCYearTotal", ZCTotal);
        map.put("SRYear", YearSRDetail);
        map.put("SRYearTotal", SRTotal);


        return map;
    }

    @Override
    public List<Base_incomeexpenditure> getBySZInformation(String type, String whereWeek) throws Exception {
        return null;
    }


    @Override
    public void updateXSTable(SalePurchase sale) {
        SalePurchase sa=new SalePurchase();
        if (sale.getSpid()!=null&&!"".equals(sale.getSpid())) {
            List<SalePurchase> xssPid = base_commodityinfoMapper.getXSSPid(sale.getSpid());
            for (SalePurchase salePurchase : xssPid) {
                if (sale.getSpmc()!=null) {
                    sa.setSpmc(sale.getSpmc());
                }else {
                    sa.setSpmc(salePurchase.getSpmc());
                }
                if (sale.getSpxh()!=null) {
                    sa.setSpxh(sale.getSpxh());
                }else {
                    sa.setSpxh(salePurchase.getSpxh());
                }
                if (sale.getSpjhsl()!=null) {
                    sa.setSpjhsl(sale.getSpjhsl());
                }else {
                    sa.setSpjhsl(salePurchase.getSpjhsl());
                }
                if (sale.getSpjhdj()!=null) {
                    sa.setSpjhdj(sale.getSpjhdj());
                }else {
                    sa.setSpjhdj(salePurchase.getSpjhdj());
                }
                if (sale.getSpjhdj()!=null&&sale.getSpjhsl()!=null) {
                    sa.setSpjhzj(sale.getSpjhdj()*sale.getSpjhsl());
                }else {
                    sa.setSpjhzj(salePurchase.getSpjhzj());
                }
                if (sale.getSpjhsfsj()!=null) {
                    sa.setSpjhsfsj(sale.getSpjhsfsj());
                }else {
                    sa.setSpjhsfsj(salePurchase.getSpjhsfsj());
                }
                if (sale.getPlanarrivedtime()!=null) {
                    sa.setPlanarrivedtime(sale.getPlanarrivedtime());
                }else {
                    sa.setPlanarrivedtime(salePurchase.getPlanarrivedtime());
                }
                sa.setSpid(sale.getSpid());
            }
            base_commodityinfoMapper.updateXSTable(sa);
            System.out.println("更新采购销售信息成功");
        }


    }


    @Override
    public void updateSZTable(SZResult szResult) {
        SZResult sz=new SZResult();
        if (szResult.getIECODE()!=null&&!"".equals(szResult.getIECODE())) {
            List<SZResult> sziecode = base_commodityinfoMapper.getSZIECODE(szResult.getIECODE());
            for (SZResult szResult2 : sziecode) {
                if (szResult.getJHJE()!=null) {
                    sz.setJHJE(szResult.getJHJE());
                }else {
                    sz.setJHJE(szResult2.getJHJE());
                }
                if (szResult.getJHYF()!=null) {
                    sz.setJHYF(szResult.getJHYF());
                }else {
                    sz.setJHYF(szResult2.getJHYF());
                }

                sz.setIECODE(szResult.getIECODE());
            }
            base_commodityinfoMapper.updateSZTable(sz);
            System.out.println("修改收支计划成功");

        }

    }

    @Override
    public JSONObject getIncomeStacking(String rwlx) {

       /*List<IncomeStacking> onlyCategory = base_commodityinfoMapper.getOnlyCategory(rwlx);//直接返回到类别中
        List<IncomeStacking> byTypeStacking = base_commodityinfoMapper.getByTypeStacking(rwlx,"其他收入");
        List<IncomeStacking> fzStacking = base_commodityinfoMapper.getByTypeStacking(rwlx, "房租收入");
        List<IncomeStacking> qjStacking3 = base_commodityinfoMapper.getByTypeStacking(rwlx, "清洁及停车费");
        List<IncomeStacking> byTypeStacking2 = base_commodityinfoMapper.getByTypeStacking(rwlx, "水电收入");
        List<String> onlyWeek = DateUtils.getTwoYearWeek();//x轴数据
        List<IncomeStacking> listLen = DateUtils.getListLen(fzStacking);
        List<IncomeStacking> listLen2 = DateUtils.getListLen(qjStacking3);
        List<IncomeStacking> listLen3 = DateUtils.getListLen(byTypeStacking);
        List<IncomeStacking> listLen4 = DateUtils.getListLen(byTypeStacking2);
        JSONObject option=new JSONObject();
        JSONObject tooltip=new JSONObject();
        tooltip.put("trigger","axis");
        JSONObject axisPointer=new JSONObject();
        axisPointer.put("type", "shadow");
        tooltip.put("axisPointer", axisPointer);
        option.put("tooltip", tooltip);

        JSONObject legend=new JSONObject();
        JSONArray data=new JSONArray();

        for (IncomeStacking Income : onlyCategory) {
            data.add(Income.getOBJECT());
        }
        legend.put("data",data);

        JSONObject grid=new JSONObject();
        grid.put("left", "10%");
        grid.put("right", "10%");
        grid.put("bottom", "10%");
        grid.put("containLabel", true);
        JSONArray datazoom=new JSONArray();
        JSONObject zoom=new JSONObject();
        zoom.put("type","slider");
        datazoom.add(zoom);

        JSONArray xAxis=new JSONArray();
        JSONArray xdata=new JSONArray();
        JSONObject object=new JSONObject();
        for (String str : onlyWeek) {
            xdata.add("<br>"+str+"</br>");
        }

        object.put("data",xdata);
        object.put("type","category");
        xAxis.add(object);

        JSONArray yAxis=new JSONArray();
        //JSONArray ydata=new JSONArray();
        JSONObject y=new JSONObject();
        //ydata.add("");
        y.put("type","value");
        yAxis.add(y);

        JSONArray series=new JSONArray();

        JSONArray sdata=new JSONArray();
        JSONObject seriess=new JSONObject();
        for (IncomeStacking qt : listLen) {


            sdata.add(qt.getJHJE());

            seriess.put("name","房租收入");
            seriess.put("type", "bar");
            seriess.put("barWidth","10");
            seriess.put("stack", "guan");
            seriess.put("data", sdata);
        }
        series.add(seriess);
        System.out.println(series);

        sdata=new JSONArray();
        seriess=new JSONObject();
        for (IncomeStacking qj : listLen2) {

            sdata.add(qj.getJHJE());

            seriess.put("name","清洁及停车费");
            seriess.put("type", "bar");
            seriess.put("barWidth","10");
            seriess.put("stack", "guan");
            seriess.put("data", sdata);
        }
        series.add(seriess);

        sdata=new JSONArray();
        seriess=new JSONObject();
        for (IncomeStacking qt : listLen3) {

            sdata.add(qt.getJHJE());

            seriess.put("name","其他收入");
            seriess.put("type", "bar");
            seriess.put("barWidth","10");
            seriess.put("stack", "guan");
            seriess.put("data", sdata);
        }
        series.add(seriess);

        sdata=new JSONArray();
        seriess=new JSONObject();
        for (IncomeStacking qt : listLen4) {

            sdata.add(qt.getJHJE());

            seriess.put("name","水电收入");
            seriess.put("type", "bar");
            seriess.put("barWidth","10");
            seriess.put("stack", "guan");
            seriess.put("data", sdata);
        }
        series.add(seriess);
        option.put("legend", legend);
        option.put("grid", grid);
        option.put("xAxis", xAxis);
        option.put("yAxis", yAxis);
        option.put("series",series);
        option.put("dataZoom", datazoom);
*/
        return null;
    }


}
